package com.boot.contorller;

import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import com.boot.business.PurchaseDTO;
import com.boot.result.Result;
import com.boot.service.BusinessService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("business")
@AllArgsConstructor
public class BusinessController {
    private BusinessService businessService;
    @PostMapping("/purchase")
    public Result purchase(@RequestBody PurchaseDTO purchaseDTO) {
        return businessService.purchaseOrder(purchaseDTO);
    }

    @GetMapping("/check-rules")
    public List<FlowRule> checkFlowRules() {
        return FlowRuleManager.getRules();
    }
}
